Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

402
Visualizações
vuetify show "v-progress-linear" while another function is running

I have a large loop during that I want to show "v-progress-linear" like so:

    <template>
      <div>
        <v-btn
          color="success"
          @click="allRun()"
        >
          Run
        </v-btn>
    
        <v-dialog
          v-model="dialog"
          hide-overlay
          persistent
        >
          <v-card
            color="primary"
            dark
          >
            <v-card-text>
              Please stand by
              <v-progress-linear
                indeterminate
              ></v-progress-linear>
            </v-card-text>
          </v-card>
        </v-dialog>
    
      </div>
    </template>
        
  <script>
    data () {
      return {
        dialog: false
      }
    },
        
 methods: {
    allRun: function () {
      this.editorRun()
      this.dialog = true
    },
    
    editorRun () {
       for (var i = 0; i < this.listModes.length; i++) {
         // do something...
       }
       this.dialog = false
    }
  }
    
  </script>

however, my "v-progress-linear" is always executed after the loop, even when I initiate it in the editorRun() before executing the loop.

How do I start "v-progress-linear" before executing a loop and disable after loop?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You may rewrite your component using async/await like this:

<template>
  <v-app>
    <div>
      <v-btn color="success" @click="allRun()"> Run </v-btn>
      <v-dialog v-model="dialog" hide-overlay persistent>
        <v-card>
          <v-card-text>
            Please stand by
            <v-progress-linear indeterminate></v-progress-linear>
          </v-card-text>
        </v-card>
      </v-dialog>
    </div>
  </v-app>
</template>

<script>
export default {
  data() {
    return {
      dialog: false,
      listModes: [1, 2, 3],
    };
  },
  methods: {
    allRun() {
      this.dialog = true;
      this.editorRun();
    },

    async editorRun() {
      for (const item of this.listModes) {
        await this.longTask(item);
      }
      this.dialog = false;
    },
    async longTask(item) {
      await new Promise(resolve => setTimeout(resolve, 500));
    }
  },
};
</script>

CodeSandbox demo link

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda